/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package apteka;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.MailSender;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.stereotype.Service;

/**
 *
 * @author Marek
 */
public class MailManager {

    @Autowired
        MailSender mailSender;

    private String serverAddress;
    private String emailAddress;

    public String getEmailAddress() {
        return emailAddress;
    }

    public void setEmailAddress(String emailAddress) {
        this.emailAddress = emailAddress;
    }

    public String getServerAddress() {
        return serverAddress;
    }

    public void setServerAddress(String serverAddress) {
        this.serverAddress = serverAddress;
    }

    public void setMailSender(MailSender mailSender) {
       this.mailSender = mailSender;
    }

    public MailManager() {

    }

    public void SendRegisterToken(String to, String token) {
        SimpleMailMessage message = new SimpleMailMessage();
        message.setFrom(emailAddress);
        message.setTo(to);
        message.setSubject("Aktywacja użytkownika w aptece internetowej");
        message.setText("Witaj!\n Aby aktywować konto w aptece internetowej kliknij w poniższy link:\n "+serverAddress+"activate.htm?token="+token);
        mailSender.send(message);
    }

}
